Neither `PopupMenuBase` nor `PopupMenuSection` are destroyable, thus the
signal connection needs to be manually disconnected to avoid leaking
both via the respective signal trackers.
This disconnects the connections in both directions when the child
`PopupMenuSection` is destroyed, which handles both cases the section
being destroyed, but also the parent menu being destroyed, because that
also triggers the destruction of all children.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4398>
(cherry picked from commit
2a923660bc1212cc0249dbb8833d28a708f089c0)
if (menuItem instanceof PopupMenuSection) {
menuItem.connectObject(
'active-changed', this._subMenuActiveChanged.bind(this),
- 'destroy', () => this.length--, this);
+ 'destroy', () => {
+ this.length--;
+ this.disconnectObject(menuItem);
+ menuItem.disconnectObject(this);
+ }, this);
this.connectObject(
'open-state-changed', (self, open) => {